import request from "@/utils/request";
import type { CartItem } from "@/types/cart";
import type { ResponseType } from "@/types/response";

enum Enum {
    cart = "/member/cart",
    selectedAll = "/member/cart/selected"
}

/*获取购物车列表的接口*/
export const fetchCartListAPI = (): Promise<ResponseType<CartItem[]>> => request.get<CartItem[], ResponseType<CartItem[]>>(Enum.cart);

/*删除购物车的接口*/
export const deleteCartAPI = (data: { ids: string[] }) => request.delete(Enum.cart, { data });

/*修改购物车商品的接口*/
export const changeCartAPI = (data: { selected?: boolean, count?: number }, id: string) => request.put(`${Enum.cart}/${id}`, data);

/*购物车全选和取消全选的接口*/
export const changeSelectedAllAPI = (data: { selected: boolean }) => request.put(Enum.selectedAll, data);
